import { Component } from '@angular/core';
import {BMIForm} from './vo/BMIForm';
import {ResultVo} from './vo/ResultVo';
import {BmiService} from './service/bmi.service';
import {getSyntheticPropertyName} from '@angular/compiler/src/render3/util';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent{
  bmiform: BMIForm;
  resultvo: ResultVo;
  imgourl:string;


  constructor(private bmiservice: BmiService){
    this.bmiform = new BMIForm();
    this.resultvo = new ResultVo();
  }


  getBMivalue() {

     console.log("身高"+this.bmiform.sg+"体重"+this.bmiform.tg);
     this.bmiservice.getBMIValue(this.bmiform)
       .then((data:any)=>{
       this.resultvo=data;
       this.getPic()
       })


  }


  getPic(){

  switch (this.resultvo.state){
    case "偏瘦":
      this.imgourl="/assets/images/1.jpg"
          break
    case "正常":
      this.imgourl="/assets/images/2.jpg"
      break
    case "过重":
      this.imgourl="/assets/images/3.jpg"
      break
    case "肥胖":
      this.imgourl="/assets/images/4.JPG"
      break

}

  }


}
